#pragma once

#include <cstdint>

namespace kanon
{
    enum class EventType
    {
        EVENT_NONE,
     
        EVENT_WINDOW_RESIZE,

        EVENT_MOUSE_LEFT_DOWN,
        EVENT_MOUSE_LEFT_UP,
        EVENT_MOUSE_RIGHT_DOWN,
        EVENT_MOUSE_RIGHT_UP,
        EVENT_MOUSE_MIDDLE_DOWN,
        EVENT_MOUSE_MIDDLE_UP,
        EVENT_MOUSE_MOVE,

        EVENT_KEY_PRESS,
        EVENT_KEY_RELEASE,
        EVENT_KEY_REPEAT,

        EVENT_CHAR,
    };

    struct EventContext
    {
        union
        {
            uint8_t u8[8];
            uint32_t u32[2];
            float f32[2];
            double f64;
        } data;
    };

    struct Event
    {
        bool handled;
        EventType type;
        EventContext context;
    };

    typedef bool (*PFN_on_event)(EventType type, void* sender, void* listener, EventContext context);

    void register_event(EventType type, void* listener, PFN_on_event callback);
    void fire_event(Event event, void* sender);
}
